package com.boatAnchorAssistant.service.controller.web;

import cn.hutool.json.JSONObject;
import com.boatAnchorAssistant.pojo.param.alarmPushLog.*;
import com.boatAnchorAssistant.pojo.vo.alarmPushLog.*;
import com.boatAnchorAssistant.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import java.util.List;

/**
 * web/报警推送日志
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/communication/alarm/record")
public class AlarmPushLogWebController {

    private final AlarmPushLogService service;

    public AlarmPushLogWebController(AlarmPushLogService service) {
        this.service = service;
    }


    /**
     * 获取报警推送日志详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getAlarmPushLog")
    public ApiResult<GetAlarmPushLogVo> getAlarmPushLog(@RequestParam("id") Long id) {
        GetAlarmPushLogVo vo = service.getAlarmPushLog(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取报警推送日志列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getAlarmPushLogList")
    public ApiResult<PageResult<GetAlarmPushLogListVo>> getAlarmPushLogList(@RequestBody GetAlarmPushLogListParam param) {
        PageResult<GetAlarmPushLogListVo> result = service.getAlarmPushLogList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取报警推送日志下拉列表
     *
     * @return
     */
    @PostMapping("/getAlarmPushLogDownList")
    public ApiResult<List<GetAlarmPushLogDownListVo>> getAlarmPushLogDownList(@RequestBody(required = false) @Valid GetAlarmPushLogDownListParam param) {
        List<GetAlarmPushLogDownListVo> list = service.getAlarmPushLogDownList(param);
        return ApiResult.ok(list);
    }


    /**
     * 接收报警推送的json
     * @param json
     * @return
     */
    @PostMapping("/insert")
    public ApiResult receiveAlarmPushLog(@RequestBody @Valid JSONObject json) {
        service.receiveAlarmPushLog(json);
        return ApiResult.ok();
    }


}

